package org.springframework.mail.javamail;


import org.apache.commons.lang3.StringUtils;

import javax.mail.MessagingException;
import javax.mail.Transport;

public class C7nJavaMailSenderImpl extends JavaMailSenderImpl {
    @Override
    protected Transport connectTransport() throws MessagingException {
        String username = getUsername();
        String password = getPassword();
        if (StringUtils.isEmpty(password)) {
            username = null;
            password = null;
        }
//        if ("".equals(username)) {  // probably from a placeholder
//
//            if ("".equals(password)) {  // in conjunction with "" username, this means no password to use
//                password = null;
//            }
//        }

        Transport transport = getTransport(getSession());
        transport.connect(getHost(), getPort(), username, password);
        return transport;
    }
}
